import { DailyListNormal } from "./DailyListNormal";
import { MuiEvent } from "../../../../../com/mui/events/MuiEvent";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { DailySpecialInfo } from "../../../model/DailySpecialInfo";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../../resource/ImagesConst";
import { SpecialActiveTitle } from "../titleBar/SpecialActiveTitle";
import { SpecialRewardList } from "../reward/SpecialRewardList";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { SpecialActiveTabBar } from "./SpecialActiveTabBar";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
type int = number;
//class DailySpecialActivityList
    
    export  class DailySpecialActivityList extends DailyListNormal
    {
        constructor(arg1: int, arg2: int)
        {
            super();
            _width = 680;
            _height = 410;
            return;
        }

        /* internal  */get infoTypeFromTabBar(): int
        {
            if (!(this._listTabBar.selectedIndex == -1) && this._listTabBar.dataProvider.length > 0) 
            {
                return this._listTabBar.dataProvider[this._listTabBar.selectedIndex].code;
            }
            return -1;
        }

        /* internal  */onActiveListChange(arg1: MuiEvent): void
        {
            this.activeDetailReq();
            return;
        }

        /* internal  */activeDetailReq(arg1: int=0): void
        {
            this._activeInfoPanel.dispose();
            this._activeRewardList.dispose();
            Dispatcher.dispatchEvent(new DataEvent(EventName.DailySpecialDetailInfoReq, this.infoTypeFromTabBar));
            return;
        }

        public updateActiveDetailInfo(arg1: DailySpecialInfo): void
        {
            if (this.infoTypeFromTabBar == arg1.code) 
            {
                this._activeInfoPanel.updateData(arg1);
                this._activeRewardList.updateData(arg1);
            }
            return;
        }

        public onGetRewardRes(arg1: int, arg2: int): void
        {
            this._activeRewardList.onGetRewardRes(arg1, arg2);
            return;
        }

        public onActiveConditionUpdate(arg1: Array<any>): void
        {
            this._activeRewardList.onActiveConditionUpdate(arg1);
            return;
        }

        protected /* override */ initUI(): void
        {
            this.initWidth();
            _bg = ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            _bg.width = 194;
            _bg.height = 399;
            addChild(_bg);
            this._bg2 = ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            this._bg2.width = 493;
            this._bg2.height = 122;
            this._bg2.x = _bg.x + _bg.width + 4;
            addChild(this._bg2);
            this._bg3 = ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            this._bg3.width = this._bg2.width;
            this._bg3.height = 273;
            this._bg3.x = this._bg2.x;
            this._bg3.y = this._bg2.y + this._bg2.height + 4;
            addChild(this._bg3);
            this.createTitleBar();
            this.createListBody();
            this.createAwardList();
            return;
        }

        protected /* override */ initWidth(): void
        {
            _titleWidth = 0;
            _listWidth = 192;
            _listHeight = 388;
            return;
        }

        protected /* override */ createTitleBar(): void
        {
            this._activeInfoPanel = new SpecialActiveTitle();
            this._activeInfoPanel.x = this._bg2.x + 5;
            this._activeInfoPanel.y = this._bg2.y + 5;
            addChild(this._activeInfoPanel);
            return;
        }

        protected /* override */ createAwardList(): void
        {
            this._activeRewardList = new SpecialRewardList(this._bg3.width - 10, this._bg3.height - 15);
            this._activeRewardList.x = this._bg3.x + 5;
            this._activeRewardList.y = this._bg3.y + 10;
            addChild(this._activeRewardList);
            return;
        }

        protected /* override */ createListBody(): void
        {
            super.createListBody();
            _scrollPane.x = _bg.x + 2;
            _scrollPane.y = _bg.y + 2;
            _scrollPane.verticalScrollPolicy = ScrollPolicy.AUTO;
            _scrollPane.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._listTabBar = new SpecialActiveTabBar();
            this._listTabBar.buttonStyleName = "SpecialActiveBtn";
            this._listTabBar.buttonFilters = [FilterConst.nameGlowFilter];
            this._listTabBar.buttonWidth = 152;
            this._listTabBar.buttonHeight = 26;
            this._listTabBar.direction = GBoxDirection.VERTICAL;
            this._listTabBar.verticalGap = 4;
            this._listTabBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.onActiveListChange);
            _scrollPane.source = this._listTabBar;
            return;
        }

        public /* override */ updateData(arg1: Array<any>, arg2: int, arg3: int=0): void
        {
            this.dispose();
            this._listTabBar.dataProvider = arg1;
            this._listTabBar.drawNow();
            _scrollPane.refreshPane();
            _scrollPane.update();
            _scrollPane.verticalScrollPosition = 0;
            this.activeDetailReq();
            return;
        }

        public updataGetRewardState(arg1: int, arg2: Array<any>): void
        {
            if (this._listTabBar.selectedItem && this._listTabBar.selectedItem.code == arg1) 
            {
                this._activeRewardList.updataGetRewardState(arg2);
            }
            return;
        }

        public /* override */ dispose(): void
        {
            return;
        }

        protected /* var */_listTabBar: SpecialActiveTabBar;

        protected /* var */_activeInfoPanel: SpecialActiveTitle;

        protected /* var */_activeRewardList: SpecialRewardList;

        protected /* var */_bg2: ScaleBitmap;

        protected /* var */_bg3: ScaleBitmap;
    }
